package com.shg.web.ztest;

import org.springframework.mail.MailException;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;

public class MailTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		try {
			JavaMailSenderImpl senderImpl = new JavaMailSenderImpl();
			// 设定mail server mail.sina.com.cn  fcy_38@sina.com
			senderImpl.setHost("smtp.sina.com");
			senderImpl.setUsername("fcy_38@sina.com");
			senderImpl.setPassword("131498");

			// 建立邮件消息
			SimpleMailMessage mailMessage = new SimpleMailMessage();
			// 设置收件人，寄件人
			// String[] array = new String[] {"xxx@163.com ","xxx@sohu.com "};
			// mailMessage.setTo(array);
			mailMessage.setTo("120003114@QQ.com");
			mailMessage.setFrom("941376006@QQ.com");
			mailMessage.setSubject("测试邮件！");
			mailMessage.setText("测试我的简单邮件发送机制！！");

			// 发送邮件
			senderImpl.send(mailMessage);

			System.out.println("邮件发送成功.....");
		} catch (MailException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
